//
//  UILabel+SpaceLine.m
//  CsdnPlus
//
//  Created by 邓建东 on 2020/2/28.
//  Copyright © 2020 CSDN. All rights reserved.
//

#import "UILabel+SpaceLine.h"



@implementation UILabel (SpaceLine)


- (void)changeLineSpaceWithSpace:(float)space {

    NSString *labelText = self.text;
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:labelText];
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    [paragraphStyle setLineSpacing:space];
    paragraphStyle.alignment = NSTextAlignmentCenter;
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [labelText length])];
    self.attributedText = attributedString;
    [self sizeToFit];

}

@end
